package handler

import (
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	user "project_user_srv/proto"
	video "project_video_srv/proto"
)

type ServerInterface interface {
	UserServerClient() user.UserClient
	VideoServerClient() video.VideoClient
}

type ServerStruct struct {
}

func NewClient() *ServerStruct {
	return &ServerStruct{}
}

func Init(addr *string) *grpc.ClientConn {
	flag.Parse()
	conn, _ := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	return conn
}

func (c *ServerStruct) UserServerClient(addr *string) user.UserClient {
	init := Init(addr)
	client := user.NewUserClient(init)
	return client
}

func (c *ServerStruct) VideoServerClient(addr *string) video.VideoClient {
	init := Init(addr)
	client := video.NewVideoClient(init)
	return client
}
